package com.HW;


import java.util.Arrays;
import java.util.Optional;
import java.util.Scanner;

/**
 * @ClassName : TSoftBackup
 * @Author : kele
 * @Date: 2023/11/5 16:07
 * @Description :
 */
public class TSoftBackup {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        handle(sc.nextLine());


    }

    public static void handle(String str) {

        Integer[] arr = Arrays.stream(str.split(",")).map(Integer::parseInt).toArray(Integer[]::new);

        Arrays.sort(arr, (a, b) -> b - a);

        int min = Arrays.stream(arr).reduce(Integer::sum).orElse(0) / 500;

        int max = arr.length;

        int res = max;
        while (min < max) {

            int mid = (min + max) >> 1;

            int[] soft = new int[mid];

            if (isValid(soft, arr, 0)) {
                res = mid;
                max = mid - 1;
            } else {
                min = mid + 1;
            }
        }
        System.out.println(res);
    }


    public static boolean isValid(int[] soft, Integer[] arr, int index) {


        if (index == arr.length) {
            return true;
        }


        int cur = arr[index];

        for (int i = 0; i < soft.length; i++) {

            if (i > 0 && soft[i] == soft[i - 1]) continue;

            if (soft[i] + cur <= 500) {
                soft[i] += cur;
                if (isValid(soft, arr, index + 1)) return true;
                soft[i] -= cur;
            }

        }
        return false;

    }
}
